Repository navigation
Conversation
… dates ## Description Follow-up to meta#9930. A Google Docs date chip pastes as a timed chip, and from UTC+12 east it lands on the next day. Google stores a chip without a time as noon UTC of its day (`tv_s` 1794916800 for Nov 17, the same in a Seoul tab and a Pacific/Kiritimati tab), and `GoogleDocsDateRule` stores that instant, so Nov 17 shows as `Tue Nov 17 2026 21:00` in Seoul and `Wed Nov 18 2026 01:00` in Pacific/Apia. A chip with `dfie_tpt` 0 now pastes as the all-day date of its UTC calendar day (`2026-11-17`). `dfie_tpt` is what tells the two apart: a chip set to 12:00 UTC has the same `tv_s` with `dfie_tpt` 2, and a chip whose time was removed keeps `dfie_tzi` but goes back to `dfie_tpt` 0. Timed chips, other `dfie_tpt` values and years outside 0000-9999 stay instants as before. A chip whose `dat_df` is `null` (which threw and dropped the pasted paragraph) or whose timestamp is out of range (which made an `Invalid Date` chip) now keeps its text. ## Changeset None, playground only. ## Test plan The payloads in the tests are real clipboard data copied from Google Docs: date chips made in a Seoul tab and in a Pacific/Kiritimati tab, a chip with its time removed, and chips at 12:00 in Seoul and in UTC. ### Before Pasting the copied date chip into the playground (Chromium `timezoneId`): ``` Asia/Seoul stored "2026-11-17T12:00:00.000Z" text "Tue Nov 17 2026 21:00" Pacific/Apia stored "2026-11-17T12:00:00.000Z" text "Wed Nov 18 2026 01:00" ``` `TZ=UTC pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeImport.test.ts packages/lexical-playground/__tests__/unit/DateTimeNodeTimeZone.test.ts` ``` AssertionError: expected [ '2026-11-17T12:00:00.000Z' ] to deeply equal [ '2026-11-17' ] TypeError: Cannot read properties of null (reading 'dfie_ts') Tests 12 failed | 14 passed (26) ``` ### After ``` Asia/Seoul stored "2026-11-17" text "Tue Nov 17 2026" Pacific/Apia stored "2026-11-17" text "Tue Nov 17 2026" ``` The 12:00 UTC timed chip still pastes as `2026-11-17T12:00:00.000Z`. ``` Tests 26 passed (26) ``` `TZ=UTC pnpm run test-unit`: 40,095 passed, 0 failed. `tsc`, `tsc-test`, eslint and prettier pass. Chromium e2e `DateTime.spec` and `HTML.spec`: 12 passed.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
lexical
@lexical/a11y
@lexical/clipboard
@lexical/code
@lexical/code-core
@lexical/code-prism
@lexical/code-shiki
@lexical/compiler
@lexical/devtools-core
@lexical/dragon
@lexical/eslint-plugin
@lexical/extension
@lexical/fast-check
@lexical/file
@lexical/hashtag
@lexical/headless
@lexical/history
@lexical/html
@lexical/internal
@lexical/link
@lexical/list
@lexical/mark
@lexical/markdown
@lexical/mdast
@lexical/offset
@lexical/overflow
@lexical/plain-text
@lexical/react
@lexical/rich-text
@lexical/selection
@lexical/table
@lexical/tailwind
@lexical/text
@lexical/utils
@lexical/y
@lexical/yjs
commit: |
There was a problem hiding this comment.
Thanks — this looks good. A Google Docs date chip with no time now pastes as an all-day date of its day, so it reads the same in every time zone, and a chip with a null dat_df or an out-of-range timestamp now keeps its text instead of throwing or becoming an Invalid Date chip. The new cases fail on main and pass on this branch, and in the playground the chip reads Tue Nov 17 2026 in Pacific/Apia, Asia/Seoul and America/New_York (before: Wed Nov 18 2026 01:00, Tue Nov 17 2026 21:00 and Tue Nov 17 2026 07:00), while a 12:00 Seoul timed chip is unchanged.
One optional, non-blocking suggestion:
packages/lexical-playground/__tests__/unit/DateTimeImport.test.ts:178-182— unlike the other cases, which come from copied chips, 'a chip with another time type' is the date-chip payload with onlydfie_tptchanged to 1, and it pins today's result, the instant2026-11-17T12:00:00.000Z. Nothing regresses, but if Google stores a time with no zone the way it stores a date-only chip (its wall clock read as UTC), this case locks in the same east-of-UTC shift for timed chips: a 12:00 chip would paste as 21:00 in Seoul. Consider replacing it with a copieddfie_tpt1 chip and asserting what that chip should show, or dropping it so a later fix doesn't have to undo it.
No changeset is needed: CONTRIBUTING.md and AGENTS.md exempt playground-only changes.
… zone as that time
## Description
A Google Docs chip whose time is shown without a time zone (`dfie_tpt` 1) keeps only its wall clock time, written as UTC: hiding the zone of a 12:00 chip set in Seoul changes `tv_s` from 03:00Z to 12:00Z, the same payload as a 12:00 UTC chip with its zone hidden. It pasted as 12:00 UTC, so `Tue Nov 17 2026 21:00` in Seoul.
It now pastes as that wall clock time in the time zone it is pasted in, the same as typing 12:00 in the picker. The node stores instants and all-day dates only, so the stored value is that local time as an instant, and other time zones show it converted. A chip that shows its time zone (`dfie_tpt` 2) keeps its instant.
## Changeset
None, playground only.
## Test plan
### Before
`TZ=UTC pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeNodeTimeZone.test.ts` (the 12:00 chip without a time zone, pasted in each zone):
```
America/New_York - "12:00" + "07:00"
Asia/Seoul - "12:00" + "21:00"
America/Santiago - "12:00" + "09:00"
Pacific/Apia - "12:00" + "01:00"
Atlantic/Azores - "12:00" + "11:00"
Tests 5 failed (5)
```
### After
```
Tests 26 passed (26)
```
Pasting the copied chip into the playground (Chromium `timezoneId`): `Tue Nov 17 2026 12:00` in Asia/Seoul and Pacific/Apia (before: `21:00` and `Wed Nov 18 2026 01:00`). `TZ=UTC pnpm run test-unit`: 40,095 passed, 0 failed.
There was a problem hiding this comment.
This looks good to me. Thanks for tracking down what dfie_tpt means and backing it with copied clipboard payloads.
- Chips with
dfie_tpt0 now paste as the all-day date of their UTC day (packages/lexical-playground/src/plugins/DateTimeExtension/index.tsx:95-106). That keeps Nov 17 on Nov 17 from UTC+12 eastward and stores the sameYYYY-MM-DDform the date picker writes for an all-day date. - Chips with
dfie_tpt1 now paste as their wall-clock time in the zone where they are pasted, the same as choosing that time in the picker. The PR description is right that showing 12:00 in every zone would need a new kind of value on the node, so leaving that for a separate change makes sense. - The
dat_df == nulland invalid-date guards (index.tsx:80-90) now fall back to the chip's text instead of throwing or creating an empty chip. - Replacing the
dfie_tpt1 case with a copied chip and asserting the local 12:00 result addresses my earlier note onDateTimeImport.test.ts. The new cases fail againstmainand pass with this change, and the five-zone test inDateTimeNodeTimeZone.test.tscovers the zone-hidden chip outside UTC.
No changeset is needed: CONTRIBUTING.md exempts playground-only changes.
Description
Follow-up to #9930. A Google Docs date chip pastes as a timed chip, and from UTC+12 east it lands on the next day. A time shown without a time zone pastes at another time. Google stores a chip without a time as noon UTC of its day (
tv_s1794916800 for Nov 17, the same in a Seoul tab and a Pacific/Kiritimati tab), andGoogleDocsDateRulestores that instant, so Nov 17 shows asTue Nov 17 2026 21:00in Seoul andWed Nov 18 2026 01:00in Pacific/Apia.A chip with
dfie_tpt0 now pastes as the all-day date of its UTC calendar day (2026-11-17).dfie_tptis what tells the two apart: a chip set to 12:00 UTC has the sametv_swithdfie_tpt2, and a chip whose time was removed keepsdfie_tzibut goes back todfie_tpt0. A chip whose time is shown without a time zone (dfie_tpt1) keeps only its wall clock time, written as UTC: hiding the zone of a 12:00 chip set in Seoul changestv_sfrom 03:00Z to 12:00Z, the same payload as a 12:00 UTC chip with its zone hidden. It now pastes as that wall clock time in the time zone it is pasted in, the same as typing it in the picker. The node stores instants and all-day dates only, so other time zones show that instant converted. Showing 12:00 in every time zone would need a third kind of value on the node, a time without a zone next to instants and all-day dates, so that is left for a separate change if it is wanted. A chip that shows its time zone (dfie_tpt2), otherdfie_tptvalues and years outside 0000-9999 stay instants as before. A chip whosedat_dfisnull(which threw and dropped the pasted paragraph) or whose timestamp is out of range (which made anInvalid Datechip) now keeps its text.Changeset
None, playground only.
Test plan
The payloads in the tests are real clipboard data copied from Google Docs: date chips made in a Seoul tab and in a Pacific/Kiritimati tab, a chip with its time removed, chips at 12:00 in Seoul and in UTC, and a 12:00 chip with its time zone hidden.
Before
Pasting the copied chips into the playground (Chromium
timezoneId):TZ=UTC pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeImport.test.ts packages/lexical-playground/__tests__/unit/DateTimeNodeTimeZone.test.tsAfter
The 12:00 UTC timed chip still pastes as
2026-11-17T12:00:00.000Z.TZ=UTC pnpm run test-unit: 40,095 passed, 0 failed.tsc,tsc-test, eslint and prettier pass. Chromium e2eDateTime.specandHTML.spec: 12 passed.